<?
	include('chksession.php');
	include('conn.php');
	session_start();
    //$data = file_get_contents("php://input");
    //$objData = json_decode($data);
	
	   $msg='';
	   $exptranid= $_REQUEST['exptranid'];
	   $expdate= $_REQUEST['expdate'];
	   $empid=  $_REQUEST['empid'];
	   $expensecat=  $_REQUEST['expensecat'];
	   $amtpaid=  $_REQUEST['amtpaid'];
	   $comment=  $_REQUEST['comment'];
	   $enteredby=$_SESSION['username'];
	   
		echo $exptranid.",".$expdate.",".$empid.",".$expensecat.",".$amtpaid.",".$comment.",".$enteredby;
	  
		//exit;
		
		
		$sqlc="select count(*) cnt from expensemast where status = 0 and exptranid='".$exptranid."'";
		$resc=mysql_query($sqlc);
		$rowc=mysql_fetch_assoc($resc);
		
		
			if($rowc['cnt']==0)
			{
				$sql="insert into expensemast(expdate,empid,expensecat,amtpaid,comment,enteredby,entrydt)
				values('".$expdate."','".$empid."','".$expensecat."','".$amtpaid."','".$comment."','".$enteredby."',sysdate())";
												
				$res=mysql_query($sql);
				if($res)
					$msg='Record saved successfully';			
			}
			else
			{
			//	$sql="update expensemast set expdate='$expdate',empid='$empid',expensecat='$expensecat',amtpaid='$amtpaid',comment='$comment',enteredby='$enteredby',entrydt=sysdate() where exptranid='$exptranid'";
				
				//echo $sql; exit;
				
				$res=mysql_query($sql);
				if($res)
					$msg='Record updated successfully...';					
			}
		
				
	    echo $msg;
?>